package com.ruoyi.basebill.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basebill.domain.WfzCwsgtzs;
import com.ruoyi.basebill.service.IWfzCwsgtzsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 手工调整数据Controller
 * 
 * @author lianxiaolong
 * @date 2022-12-17
 */
@RestController
@RequestMapping("/basebill/cwsgtzs")
public class WfzCwsgtzsController extends BaseController
{
    @Autowired
    private IWfzCwsgtzsService wfzCwsgtzsService;

    /**
     * 查询手工调整数据列表
     */
    @PreAuthorize("@ss.hasPermi('basebill:cwsgtzs:list')")
    @GetMapping("/list")
    public TableDataInfo list(WfzCwsgtzs wfzCwsgtzs)
    {
        startPage();
        List<WfzCwsgtzs> list = wfzCwsgtzsService.selectWfzCwsgtzsList(wfzCwsgtzs);
        return getDataTable(list);
    }

    /**
     * 导出手工调整数据列表
     */
    @PreAuthorize("@ss.hasPermi('basebill:cwsgtzs:export')")
    @Log(title = "手工调整数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WfzCwsgtzs wfzCwsgtzs)
    {
        List<WfzCwsgtzs> list = wfzCwsgtzsService.selectWfzCwsgtzsList(wfzCwsgtzs);
        ExcelUtil<WfzCwsgtzs> util = new ExcelUtil<WfzCwsgtzs>(WfzCwsgtzs.class);
        util.exportExcel(response, list, "手工调整数据数据");
    }

    /**
     * 获取手工调整数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('basebill:cwsgtzs:query')")
    @GetMapping(value = "/{fid}")
    public AjaxResult getInfo(@PathVariable("fid") Long fid)
    {
        return success(wfzCwsgtzsService.selectWfzCwsgtzsByFid(fid));
    }

    /**
     * 新增手工调整数据
     */
    @PreAuthorize("@ss.hasPermi('basebill:cwsgtzs:add')")
    @Log(title = "手工调整数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WfzCwsgtzs wfzCwsgtzs)
    {
        wfzCwsgtzs.setFcreator(getUsername());
        wfzCwsgtzs.setFlastupdateuser(getUsername());
        return toAjax(wfzCwsgtzsService.insertWfzCwsgtzs(wfzCwsgtzs));
    }

    /**
     * 修改手工调整数据
     */
    @PreAuthorize("@ss.hasPermi('basebill:cwsgtzs:edit')")
    @Log(title = "手工调整数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WfzCwsgtzs wfzCwsgtzs)
    {
        wfzCwsgtzs.setFlastupdateuser(getUsername());
        return toAjax(wfzCwsgtzsService.updateWfzCwsgtzs(wfzCwsgtzs));
    }

    /**
     * 删除手工调整数据
     */
    @PreAuthorize("@ss.hasPermi('basebill:cwsgtzs:remove')")
    @Log(title = "手工调整数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fids}")
    public AjaxResult remove(@PathVariable Long[] fids)
    {
        return toAjax(wfzCwsgtzsService.deleteWfzCwsgtzsByFids(fids));
    }
}
